<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\date\DatePicker;
use yii\web\View;
/* @var $this yii\web\View */
/* @var $model app\models\ClassModel */
/* @var $form yii\widgets\ActiveForm */
$js='function myFunction(){
		var x=document.getElementById("classmodel-type").value;
		if(x=="缺勤")
		{
			document.getElementById("keshishu").style.display="none";
			document.getElementById("cishu").style.display="inline";
		}else
		{
			document.getElementById("cishu").style.display="none";
			document.getElementById("keshishu").style.display="inline";
		}
	
	
}';
$js1='document.getElementById("keshishu").style.display="none"'.';';
$url=\Yii::getAlias('@web');
$js3=<<< Js
function myAjax(){
		var x=$("#classmodel-stu_id").val();
		$.ajax({
                    url: '$url/personinfo/getname?stuid='+x,
                    type: 'get',
                    dataType: 'text',
                    success: function (data) {
                       $("#classmodel-name").val(data);
                    }
                });
}
Js;

$this->registerJs($js, View::POS_HEAD, 'my-options');
$this->registerJs($js1, View::POS_END, 'my');
$this->registerJs($js3, View::POS_END, 'myAjax');
?>

<div class="class-model-form">
    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'stu_id')->textInput(['maxlength' => true,
    		'onblur'=>'myAjax()',
    ]) ?>
    <?= $form->field($model, 'name')->textInput(['maxlength' => true,
    		'readonly'=>true,
    ]) ?>
    <?= $form->field($model, 'year')->dropDownList([(date('Y').'-'.(date('Y')+1))=>(date('Y').'-'.(date('Y')+1)),
    																						((date('Y')-1).'-'.date('Y'))=>((date('Y')-1).'-'.date('Y')),
    																						((date('Y')-2).'-'.(date('Y')-1))=>((date('Y')-2).'-'.(date('Y')-1)),
    																							((date('Y')-3).'-'.(date('Y')-2))=>((date('Y')-3).'-'.(date('Y')-2))])
    																								->label('学年')	 ?>

    <?= $form->field($model, 'semester')->dropDownList(['1'=>'1','2'=>'2']) ?>




    <?= $form->field($model, 'time')->widget(DatePicker::classname(), [
        'options' => ['placeholder' => 'Enter birth date ...'],
        'pluginOptions' => [
            'autoclose'=>true,
            'format' => 'yyyy.mm.dd'
        ]
    ])->label('日期');
    ?>


    <?= $form->field($model, 'jieshu')->dropDownList(['第1~2节'=>'第1~2节','第1~3节'=>'第1~3节',
    		'第3~4节'=>'第3~4节','第4~5节'=>'第4~5节','第5~6节'=>'第5~6节','第6~8节'=>'第6~8节',
    		'第7~8节'=>'第7~8节','第9~10节'=>'第9~10节','第9~11节'=>'第9~11节','第10~12节'=>'第10~12节'])?>

    <?= $form->field($model, 'course')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'teacher')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'type')->dropDownList(['缺勤'=>'缺勤','迟到'=>'迟到','早退'=>'早退'],[
    'onchange'=>'myFunction()',		
    ]) ?>
	<h5 id="cishu"><b>学时数</b></h5>
	<h5 id="keshishu"><b>次数</b></h5>
    <?= $form->field($model, 'num')->textInput(['maxlength' => true,
    		])->label('');?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '添加' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
